﻿using AutoMapper;
using EFSQLiteOneToManay.AutoMapper;
using EFSQLiteOneToManay.ModelDTO;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EFSQLiteOneToManay
{
    public class TestAutomapper
    {
        public InspRecord TestRecord()
        {
            try
            {
                var dto = (new GenerateTempData()).GetDefaultRecordDTO("ABCDJKKDG");
                Stopwatch sw = new Stopwatch();
                sw.Start();
                InspRecord record = dto.MapTo<InspRecord>().ConfigRecord();
                sw.Stop();
                Console.WriteLine("Record第一次转换耗时：" + sw.ElapsedMilliseconds);
                sw.Restart();
                var record2 = (new CustomerTypeConverter()).ManualConvertGroup(dto);
                sw.Stop();
                Console.WriteLine("Record第二次转换耗时：" + sw.ElapsedMilliseconds);
                sw.Restart();
                InspRecordDTO rdto = Mapper.Map<InspRecord, InspRecordDTO>(record);
                sw.Stop();
                Console.WriteLine("Record第三次转换耗时：" + sw.ElapsedMilliseconds);
                return record;
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("Record:{0}", ex.Message));
                return null; 
            }
        }
    }
}
